package cn.shop.admin.component.withdraw;

import com.alipay.api.CertAlipayRequest;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @author : 李一涵
 * @date : Created in 2022-3-23 11:06
 * @description :
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "alipay")
public class AliConfig {

	private String gatewayUrl;
	private String appId;
	private String privateKey;
	private String charset;
	private String signType;
	private String appCertPath;
	private String alipayCertPath;
	private String alipayRootCertPath;

	public CertAlipayRequest certAlipayRequest() {
		CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
		//设置网关地址
		certAlipayRequest.setServerUrl(gatewayUrl);
		//设置应用Id
		certAlipayRequest.setAppId(appId);
		//设置应用私钥
		certAlipayRequest.setPrivateKey(privateKey);
		//设置请求格式，固定值json
		certAlipayRequest.setFormat("json");
		//设置字符集
		certAlipayRequest.setCharset(charset);
		//设置签名类型
		certAlipayRequest.setSignType(signType);
		//设置应用公钥证书路径
		certAlipayRequest.setCertPath(appCertPath);
		//设置支付宝公钥证书路径
		certAlipayRequest.setAlipayPublicCertPath(alipayCertPath);
		//设置支付宝根证书路径
		certAlipayRequest.setRootCertPath(alipayRootCertPath);
		return certAlipayRequest;
	}

}
